package com.zxk.blog.controller;


import com.zxk.api.service.FundService;
import com.zxk.blog.service.BlogTestService;
import com.zxk.core.common.util.JsonData;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.Assert;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

@Api("测试接口")
@RestController
public class TestController {

    @Autowired
    private FundService fundService;
    @Autowired
    private BlogTestService testService;

    @ApiOperation(value="测试",notes="测试")
    @GetMapping(value = {"/"})
    public Object test(@RequestParam(required = false) String str1,@RequestParam(required = false) String str2){
        System.out.println(str1+str2);
        return fundService.findAll();
    }


    private Logger logger = LoggerFactory.getLogger(this.getClass());


    @GetMapping("/log")
    public Object testLog(){

        logger.debug("this is debug level");
        logger.info("this is info level ");
        logger.warn("this is warn level ");
        logger.error("this is error level");
        return JsonData.buildSuccess();
    }

    @GetMapping("/layer-cache")
    public Object layertest1(@RequestParam String key) {
        String str = testService.getmsg(key);
        return str;
    }

    @GetMapping("/test-exception")
    public Object testException() {
        int i = 5/0;
        return i;
    }
    @GetMapping("/test-assert")
    public Object testAssert() {
        List<String> stringList = new ArrayList<>();
        Assert.notEmpty(stringList,"不能为空");
        return "hello";
    }
}
